package info.nightbrest.agt.client.view.impl;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.*;
import com.google.inject.Inject;
import info.nightbrest.agt.client.view.LoginPanelView;

public class LoginPanelViewImpl extends Composite implements LoginPanelView
{
	private Presenter presenter;

	interface LoginPanelViewUiBinder extends UiBinder<Widget, LoginPanelViewImpl>
	{
	}
	private static LoginPanelViewUiBinder ourUiBinder = GWT.create(LoginPanelViewUiBinder.class);

	@UiField
	TextBox loginTextBox;
	@UiField
	PasswordTextBox passwordTextBox;
	@UiField
	Button loginButton;
	@UiField
	DisclosurePanel disclosurePanel;

	@Inject
	public LoginPanelViewImpl()
	{
		initWidget(ourUiBinder.createAndBindUi(this));
		disclosurePanel.setOpen(true);
		disclosurePanel.setAnimationEnabled(true);
	}

	@Override
	public void setCollapsible()
	{
		if (disclosurePanel.getHeader() == null)
		{
		}
	}

	@Override
	public String getLogin()
	{
		return loginTextBox.getText();
	}

	@Override
	public String getPassword()
	{
		return passwordTextBox.getText();
	}

	@Override
	public void setPresenter(Presenter presenter)
	{
		this.presenter = presenter;
	}

	@UiHandler("loginButton")
	public void onLoginButtonClicked(ClickEvent event)
	{
		if (presenter != null)
		{
			presenter.onLoginButtonClicked();
		}
	}
}